//
//  ProvinceDAO.m
//  ItboyeLibrary
//
//  Created by hebidu on 15/9/21.
//  Copyright © 2015年 Boye. All rights reserved.
//

#import "ProvinceDAO.h"
#import "ProvinceEntity.h"

@implementation ProvinceDAO


/**
 *  查询
 *
 *  @param withArgumentsInArray 参数
 *
 *  @return 数组
 */
-(id) query:(NSArray *)arguments{
    
    NSString * path = [[NSBundle mainBundle] pathForResource: SQLLITE3_DATABASE_NAME  ofType:@"db"];
    
    BOOL result = [[SqliteHelper sharedInstance] openDB:path];
    
    NSString *queryStr = @"select id,provinceID,province,countryid from common_province";
    if (result) {
        
        FMDatabase * database =    [SqliteHelper sharedInstance].database;
        
        FMResultSet * resultSet =  [database executeQuery:queryStr withArgumentsInArray:nil];
        NSMutableArray * resultArray = [[NSMutableArray alloc]init];
        while ([resultSet next]) {
            ProvinceEntity * entity = [[ProvinceEntity alloc]init];
            entity.province = [resultSet stringForColumn:@"province"];
            entity.provinceID = [resultSet stringForColumn:@"provinceID"];
            [resultArray addObject:entity];
            NSLog(@"ProvinceEntity:%@",entity.description);
        }
        [[SqliteHelper sharedInstance] closeDB];
        return resultArray;
    }
    return nil;
}

-(id)update:(id)obj{
    
    return nil;
}

/**
 *  查询
 *
 *  @param withArgumentsInArray 参数
 *
 *  @return 数组
 */
-(id) add:(id)obj{
    
    return nil;
}

/**
 *  删除
 *
 */
-(id) delete:(id)obj{
    
    return nil;
}


@end
